﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Domen;
using Sesija;
using System.Net;
using System.IO;
using System.Drawing;
using System.Drawing.Imaging;
using System.Threading;
using System.Web.Services.Description;
using System.Web.Services;


namespace LFSStatistika
{
    public partial class Default : System.Web.UI.Page
    {
    
        BrokerLFS brokerLFS = BrokerLFS.GetInstance();
        public delegate void MethodInvoker();
        List<DriverStats> driverStatsList = new List<DriverStats>();
        LFSSignature.LFSServisRef.Driver driver = new LFSSignature.LFSServisRef.Driver();

        //LFSServiceRef.Driver driver = new LFSServiceRef.Driver();
           

        protected void Page_Load(object sender, EventArgs e)
        {

            
        }

        protected override void OnLoadComplete(EventArgs e)
        {
            try
            {
                imgLfs.ImageUrl = @"~\SlikeUser\" + driver.Username + "lfs.gif";
                //txtPobede.Text = driverStatsList[0].RaceWon.ToString();
            }
            catch (Exception)
            {

                txtPobede.Text = "0";
            }
        }
       
        protected void btnPobede_Click(object sender, EventArgs e)
        {

            Driver driver2 = new Driver();
            driver.Username = txtUsername.Text;
            driver.IDK = txtIDK.Text;

            driverStatsList = brokerLFS.ReturnStatisticsPST(driver2);
            txtPobede.Text = driverStatsList[0].RaceWon.ToString();
        }


        protected void btnImage_Click(object sender, EventArgs e)
        {
            try
            {
                
                driver.Username = txtUsername.Text;
                driver.IDK = txtIDK.Text;
                driver.Password = Server.MapPath("~");
                string serverUrl = Server.MapPath("~");

            

                LFSSignature.LFSServisRef.LFSServisSoapClient klijent = new LFSSignature.LFSServisRef.LFSServisSoapClient();
                klijent.KreiranjeSlikeServis(driver);
                //Ponovo:
                //lfsServiceSoapKlijent.KreiranjeSlikeServis(driver);
              

                object sender2 = new object();
                EventArgs e2 = new EventArgs();
                OnLoadComplete(e2);
            }
            catch (Exception ex)
            {

                txtPobede.Text = ex.Message;
            }
           
 
        }

        public void PozoviServis()
        {
            
           // imgLfs.ImageUrl = @"~\SlikeUser\" + driver.Username + "lfs.gif";
          
           // goto Ponovo;
        }

        protected void btnSlika_Click(object sender, EventArgs e)
        {
            List<DriverStats> driverStatsList = new List<DriverStats>();
            Driver driver = new Driver();
            driver.Username = txtUsername.Text;
            driver.IDK = txtIDK.Text;

            driverStatsList = brokerLFS.ReturnStatisticsPST(driver);
            txtPobede.Text = driverStatsList[0].RaceWon.ToString();

        }
    }
}